<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.AppName}"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:form id="AccionListForm">              

                <p:panel header="#{bundle.Setting}">

                    <p:fieldset legend="#{bundle.SettingPersonal}" style="margin: auto; width: 80%;">  

                        <h:panelGrid columns="2" cellpadding="30">  
                            <h:panelGrid columns="1">
                                <p:graphicImage value="resources/images/profiles/#{loginBean.user.fotoUrl}" />  
                                <p:fileUpload mode="simple" sizeLimit="10000" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" />
                            </h:panelGrid>
                            <h:panelGrid columns="2" cellpadding="10">  

                                <h:outputLabel value="#{bundle.CreateUsuarioLabel_nombre}" for="nombre" styleClass="ui-label"/>                                 
                                <h:outputText id="nombre" value="#{settingBean.selected.nombre}" />

                                <h:outputLabel value="#{bundle.CreateUsuarioLabel_cedula}" for="cedula" styleClass="ui-label"/>                                 
                                <h:outputText id="cedula" value="#{settingBean.selected.cedula}" />

                                <h:outputLabel value="#{bundle.ViewUsuarioLabel_descripcion}" styleClass="ui-label"/> 
                                <p:inputTextarea value="#{settingBean.selected.descripcion}" maxlength="300" />

                                <h:outputLabel value="#{bundle.ViewUsuarioLabel_alias}" styleClass="ui-label"/> 
                                <p:inputText value="#{settingBean.selected.alias}" maxlength="45"/>

                                <h:outputLabel value="#{bundle.ViewUsuarioLabel_email}" styleClass="ui-label"/> 
                                <p:inputText  value="#{settingBean.selected.email}" maxlength="45" validatorMessage="#{settingBean.selected.email} No es un correo Valido" >
                                    <f:validateRegex pattern="[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]" />
                                </p:inputText>

                                <h:outputLabel value="#{bundle.ViewUsuarioLabel_telefono}" styleClass="ui-label"/> 
                                <p:inputMask mask="+99-999-999-9999" value="#{settingBean.selected.telefono}" />
                            </h:panelGrid>                          
                        </h:panelGrid>  
                    </p:fieldset>  
                    <p:fieldset legend="#{bundle.SettingSystem}" style="margin: auto; width: 80%;">  
                        <h:panelGrid columns="3" cellpadding="20">  
                            <h:outputLabel value="#{bundle.ViewUsuarioLabel_notificacionIdnotificacion}" styleClass="ui-label"/>
                            <p:selectOneMenu id="notificacionIdnotificacion" value="#{settingBean.selected.notificacionIdnotificacion}">
                                <f:selectItems value="#{notificacionController.items}"
                                               var="notificacionIdnotificacionItem"
                                               itemValue="#{notificacionIdnotificacionItem}"
                                               itemLabel="#{notificacionIdnotificacionItem.nombre}"/>
                                <f:converter binding="#{notificacionConverter}"/>
                            </p:selectOneMenu>    
                            <h:outputText value="#{bundle.SettingMessageNotification}"/>

                            <h:outputLabel value="#{bundle.SettingLabelWriteSubjects}" styleClass="ui-label" rendered="#{loginBean.isAdmin}"/>
                            <p:commandButton value="#{bundle.SettingButtonWriteSubjects}" onclick="confirmation.show();" type="button" rendered="#{loginBean.isAdmin}"/>
                            <h:outputText value="#{bundle.SettingMessageWriteSubjects}" rendered="#{loginBean.isAdmin}"/>

                        </h:panelGrid>  
                    </p:fieldset>  
                    <p:panel style="margin: auto; width: 80.999%; text-align: right">
                        <p:commandButton actionListener="#{settingBean.save}" value="#{bundle.Save}" update=":growl"/>

                    </p:panel>

                </p:panel>
                <p:dialog id="confirmDialog" header="Iniciando proceso de Actualización" widgetVar="confirmation"  resizable="false" rendered="#{loginBean.isAdmin}">

                    <h:outputLabel value="#{bundle.DialogConfirmAction}"/>
                    <h:panelGrid columns="2" cellspacing="5">
                        <p:commandButton id="confirm" value="#{bundle.Yes}" update=":growl" oncomplete="confirmation.hide()" actionListener="#{settingBean.readAndWriteAllSubjects}" />  
                        <p:commandButton id="decline" value="#{bundle.No}" onclick="confirmation.hide()" type="button" />
                    </h:panelGrid>
                </p:dialog>
            </h:form>
        </ui:define>

    </ui:composition>
</html>